﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tracker.Domain.DTOs;
using Tracker.Domain.Entities;

namespace Tracker
{
    public static class Mapper
    {
        public static PositionDTO Map(this Position src)
        {
            var dto = new PositionDTO();
            dto.ID = src.ID;
            dto.Latitude = src.Latitude;
            dto.Longitude = src.Longitude;
            dto.InsertDate = src.InsertDate;
            dto.Address1 = src.Address.Address1;
            dto.Address2 = src.Address.Address2;
            dto.City = src.Address.City;
            dto.State = src.Address.State;
            dto.Zip = src.Address.Zip;
            return dto;
        }

        public static IList<PositionDTO> Map(this IEnumerable<Position> source)
        {
            var dtos = new List<PositionDTO>();

            if (source != null)
            {
                foreach (var src in source)
                {
                    dtos.Add(src.Map());
                }
            }

            return dtos;
        }

        public static UserDTO Map(this User src)
        {
            var dto = new UserDTO();
            dto.ID = src.ID;
            dto.Username = src.Username;
            dto.Email = src.Email;
            dto.InsertDate = src.InsertDate;
            dto.ModifiedDate = src.ModifiedDate;
            return dto;
        }

        public static IList<UserDTO> Map(this IEnumerable<User> source)
        {
            var dtos = new List<UserDTO>();

            foreach (var src in source)
            {
                dtos.Add(src.Map());
            }

            return dtos;
        }
    }
}
